<extend name="Public/base" />
 
<block name="body">
    <div class="main-title">
        <h2>新增商品</h2>
    </div>
    <form action="{:U()}" method="post" class="form-horizontal" enctype="multipart/form-data">
        <div class="form-item">
            <label class="item-label">品名</label>
            <div class="controls">
                <input type="text" class="text input-large" name="title" value="">
            </div>
        </div>
        <div class="form-item">
            <label class="item-label">所属类别</label>
            <div class="controls" id="select">
                <select name="fid" class="fl">
                    <option value="">请选择</option>
                    <volist name="res" id="vo">
                        <option value="{$vo.id}">{$vo.title}</option>
                    </volist>
                </select>
            </div>
        </div>
        <div class="form-item">
            <label class="item-label">描述</label>
            <div class="controls">
                <input type="text" class="text input-large" name="des" value="">
            </div>
        </div>
        <div class="form-item">
            <label class="item-label">价格</label>
            <div class="controls">
                <input type="text" class="text input-large" name="price" value="">
            </div>
        </div>
        
        <div class="form-item">
            <label class="item-label">状态<span class="check-tips">（显示或关闭）</span></label>
            <div class="controls">
            <label class="radio">
                <input type="radio"name="status" value="1">显示
            </label>
            <label class="radio">
                <input type="radio"name="status" value="0">不显示
            </label>

            </div>
        </div>
        
        <div class="form-item">
            <button class="btn submit-btn ajax-post" type="submit" target-form="form-horizontal">确 定</button>
            <button class="btn btn-return" onclick="javascript:history.back(-1);return false;">返 回</button>
        </div>
    </form>
</block>

<block name="script">
    
    <script type="text/javascript">
        $(function(){
            $("#select").on("change",".fl",function(){
                var id= $(this).val();
                //alert(id);
                console.log(id);
                var t= $(this);
                $.ajax({
                    type:"GET",
                    url:"{:U('Shop/ajaxGet')}",
                    data:{id:id},
                    success:function(msg){
                        if(msg.status==1){
                            t.nextAll().remove();
                            $("#select").append(msg.data);
                        }else{
                            t.nextAll().remove();
                        }
                    }
                });

            });

        });



        //导航高亮
        highlight_subnav('{:U('Shop/index')}');

    </script>
</block>